//
// Copyright (C) [2024] Xingyun Integrated Circuit, Inc.
//
// GreenCode was a private technology asset of Xingyun Integrated Circuit， Inc （Confidential）
//  Author: Shawn.Tan
//  Date : 2025.10.28
//
//  History : Initial Version 2025.10.28
//

//
#ifndef Green_AddressTableManagerGPGPU_H
#define Green_AddressTableManagerGPGPU_H

#include "AddressTableManager.h"
#include "Notify.h"
#include "NotifyDefines.h"

namespace Green {

  /*!
   \class AddressTableManagerGPGPU
   \brief GPGPU layer module for managing all address tables.
  */
  class AddressTableManagerGPGPU : public AddressTableManager, public NotificationReceiver {
  public:
    DEFAULT_CONSTRUCTOR_DEFAULT(AddressTableManagerGPGPU); //!< Default constructor
    SUBCLASS_DESTRUCTOR_DEFAULT(AddressTableManagerGPGPU); //!< Destructor
    ASSIGNMENT_OPERATOR_ABSENT(AddressTableManagerGPGPU);

    Object* Clone() const override { return new AddressTableManagerGPGPU(*this); } //!< Return a cloned Object of the same type and same contents as the Object being cloned.
    const char* Type() const override { return "AddressTableManagerGPGPU"; } //!< Return a string describing the current state of the Object.

    void Setup(Generator* pGen) override; //!< Setup Constructor.
    void GetReloadRegisters(cuint32 targetMemBank, cuint32 targetEl, std::map<std::string, uint64>& reloadMap) const override; //!< Get index registers requiring updates along with their respective target values.
    uint64 GenerateNewTable(uint64 baseAddress, uint64 tableSize, EMemBankType bankType) override; //!< Generate a new address table in GPGPU Layer.
  protected:
    AddressTableManagerGPGPU(const AddressTableManagerGPGPU& rOther); //!< Copy constructor.
    void HandleNotification(const NotificationSender* sender, ENotificationType eventType, Object* pPayload) override; //!< called when privilege level changes 
    void UpdateCurrentAddressTable() override; //!< Called to update address table manager.
  };

}
#endif
